| {% extends "background/base.html" %}
block pagetitle
	| : 内容替换
- block content
	#NAVID(data-nav="replace")
	.row
		.col-xs-6
			.panel.panel-primary
				.panel-heading 替换规则
					button.btn.btn-sm.btn-success.pull-right(data-target="#myModal", data-toggle="modal") 创建
				.panel-body
					table.table
						thead
							tr
								td 规则
								td(style="width:150px;") 操作
						tbody
							- for rep in replace_rule
								tr
									td= rep
									td.table-action
										button.btn.btn-xs.btn-primary.apply-rule(data-pk="#{rep}") 应用
										a.btn.btn-xs.btn-success(href="{%url 'bbg:edit_rule' rep.db_data.pk%}") 编辑
										a.btn.btn-xs.btn-danger(href="{%url 'bbg:delete_rule' rep.db_data.pk%}") 删除
		.col-xs-6
			.panel.panel-primary
				.panel-heading 替换历史
				.panel-body
	#myModal.modal.fade(tabindex="-1", role="dialog", aria-labelledby="myModalLabel", aria-hidden="true")
		.modal-dialog
			.modal-content
				form#newRuleForm.form-horizontal(action=".", method="POST")
					.modal-header
						button.close(data-dismiss="modal")
							span(aria-hidden="true") &times;
							span.sr-only Close
						h4#myModalLabel.modal-title 创建替换规则
					.modal-body
						| {% csrf_token %}
						- with create_rule_form as CRF
							.form-group(class="{%if CRF.rule_res.errors%}has-error{%endif%}")
								label.col-lg-2.control-label(for="inputRe")!= CRF.rule_res.label
								.col-lg-10
									input#inputRe.form-control(name="rule_res", type="text", value="{{CRF.rule_res.value|default:''}}")
									span.help-block!= CRF.rule_res.errors
							.form-group(class="{%if CRF.replace_to.errors%}has-error{%endif%}")
								label.col-lg-2.control-label(for="inputReplace")!= CRF.replace_to.label
								.col-lg-10
									input#inputReplace.form-control(type="text", value="{{CRF.replace_to.value|default:''}}", name="replace_to")
									span.help-block!= CRF.replace_to.errors
						.modal-footer
							button.btn.btn-default.btn-raised(data-dismiss="modal") 关闭
							button.btn.btn-primary.btn-raised(type="submit") 保存

- block footerjs
	script
		$(function(){
			{% if create_rule_form.errors or edit_rule %}
			$("#myModal").modal('show')
			{% endif %}
		});
